<?php
/**
 * Author: Administrator
 * Date: 2022/8/3 1:45
 */

namespace DesignPatterns\Behavioral\Specification;


class PriceSpecification extends AbstractSpecification
{
    protected $max;
    protected $min;

    public function setMax($max) {
        $this->max = $max;
    }

    public function setMin($min) {
        $this->min = $min;
    }

    public function isSatisfiedBy(Item $item)
    {
        if (!empty($this->max) && $this->max < $item->getPrice()) {
            return false;
        }
        if (!empty($this->min) && $this->min > $item->getPrice()) {
            return false;
        }
        return true;
    }
}